﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class StateManager : IActorManagerChild
{
    [SerializeField]
    public float HP = 15.0f;
    public float MAXHP = 15.0f;

    [Header("1st order states")]
    public bool isGround;
    public bool isJump;
    public bool isFall;
    public bool isRoll;
    public bool isJab;
    public bool isAttack;
    public bool isHit;
    public bool isDie;
    public bool isBlocked;
    public bool isDefense;

    [Header("2st order states")]
    public bool isImmortal;


    // Start is called before the first frame update
    void Start()
    {
        HP = MAXHP;
    }

    // Update is called once per frame
    void Update()
    {
        isGround = am.ac.CheckState("ground");
        isJump = am.ac.CheckState("jump");
        isFall = am.ac.CheckState("fall");
        isRoll = am.ac.CheckState("roll");
        isJab = am.ac.CheckState("jab");
        isAttack = am.ac.CheckStateTag("attack");
        isHit = am.ac.CheckState("hit");
        isDie = am.ac.CheckState("die");
        isBlocked = am.ac.CheckState("blocked");
        isDefense = am.ac.CheckState("defense1h", "Defense");
        isImmortal = isJab || isRoll;
    }

    public void AddHP(float val) {
        if (HP < 0.1f) {
            return;
        }
        HP += val;
        HP = Mathf.Clamp(HP, 0, MAXHP);        
    }
}

